package com.tedu.api;

import org.junit.Test;

import java.util.Locale;

public class 作业1 {
    //1.输出字符串”hellojava“的字符串长度
    @Test
    public void testLength() {
        String str = "hello java";//9
        System.out.println(str.length());
    }
    //2.输出”HelloJava“中”o“的位置
    //3.输出其中下标位为5处开始第一次出现以”o“的位置
    @Test
    public void testInderOf() {
        String str = "HelloJava";
        int index = str.indexOf("o");
        System.out.println("打印下标位" + index);
        index = str.indexOf("o", 5);
        System.out.println("指定下标位" + index);
    }

    //4.截取hello 5.截取java
    @Test
    public void testSubString() {
        String url = "HelloJava";
        url=url.substring(0,5);
        System.out.println("截取子字符串" + url);
        String a="HelloJava";
        a=a.substring(5);
        System.out.println(a);
    }
    //6.去掉两边的空格
    @Test
    public void testTrim() {
        String str = " HelloJava ";
        str=str.trim();
        System.out.println("去掉空格" + str);
 }
    //7.输出”j“
    @Test
    public void testCharAt() {
        String str = "HelloJava";
        char c = str.charAt(5);
        System.out.println("获取对应的字符" + c);
    }
    //8.转换大小写
    @Test
    public void testTrims() {
        String str = "HelloJava";
        str = str.toUpperCase();
        System.out.println("转换为大写" + str);
        str=str.toLowerCase();
        System.out.println("转换为小写"+str);
    }
}
